﻿using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Windows;
using System.Windows.Controls;



namespace WindowsFormsApp1.font
{
    /// <summary>
    /// UserControl1.xaml 的交互逻辑
    /// </summary>
    public partial class UserControl1 : UserControl
    {



       string connectionString = System.Configuration.ConfigurationSettings.AppSettings["connectionstring"];
      

        string sql = "select CARD_NAME from T_CARDINFO where CARD_STAUTS = '1' and CARD_PRINTSTAUTS = '2'";
        public  UserControl1()
        {
            InitializeComponent();
            



        }
       // private static SqlConnection connection;
        public void BindData()
        {
            DataSet ds = new DataSet();
            using (SqlConnection sqlcn = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand(sql, sqlcn))
                {

                    SqlDataAdapter adapter = new SqlDataAdapter();
                    sqlcn.Open();
                    adapter.SelectCommand = cmd;
                    adapter.Fill(ds, "province");
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {

                        lb.Items.Add(ds.Tables[0].Rows[i]["CARD_NAME"] + "  ");
                    }

                  
                }
               
            }
           


        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }
    }
}
